<template>
	<view class="bg-white radius-lg margin-bottom padding">
		<view class="flex align-center justify-between margin-top-sm">
			<view class="flex align-center">
				<view class='cu-avatar round lg ov-h'>
					<image :src="`${$hd.baseUrl}/images/farmer.png`" mode="aspectFit"></image>
				</view>
				<view class="margin-left-sm">
					<view class="text-black text-bold text-lg">
						{{flyerName || '飞手'}}
					</view>
					<view class="text-gray margin-top-xs">
						完成您的订单
					</view>
				</view>
			</view>

		</view>

		<view class="flex align-center justify-between margin-tb">
			<view class="text-lg text-black text-bold">
				总体评价：
			</view>
			<uv-rate activeColor="#0BCA89" size="24" :count="count" v-model="commentStar"></uv-rate>
			<view class="color-green">
				{{textObj[commentStar]}}
			</view>
		</view>
		<uv-textarea v-model="commentContent"></uv-textarea>
		<view class="foot-box">
			<button class="cu-btn bg-green flex-sub" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				count: 5,
				commentStar: 5,
				textObj: {
					1: '非常差',
					2: '差',
					3: '好',
					4: '很好',
					5: '非常好',
				},
				commentContent: '',
				orderId: ''
			}
		},
		onLoad(opt) {
			this.orderId = opt.id
			this.flyerName = opt.flyerName
		},
		methods: {
			submit() {
				// orderId,commentStar,commentContent
				this.$http.post(`/cadre/assignOrder/addComment`, {
					orderId: this.orderId,
					commentStar: this.commentStar,
					commentContent: this.commentContent,
				}).then(res => {
					if(res.code == 200) {
						uni.showToast({
							icon: 'success',
							title: "评价成功"
						})
						uni.navigateBack()
					} else {
						uni.showToast({
							icon: 'fail',
							title: res.msg
						})
					}
					
				})
			}
		},
	}
</script>

<style scoped>
	.foot-box {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx;
		background-color: #fff;
	}
</style>